import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore('user', () => {
  const phone = ref('')

  const setUser = (userPhone) => {
    phone.value = userPhone
    localStorage.setItem('userInfo', JSON.stringify({ phone: userPhone }))
  }

  const clearUser = () => {
    phone.value = ''
    localStorage.removeItem('userInfo')
  }

  return { phone, setUser, clearUser }
})
